package com.rxyb.rabbitmq.config.queue;

import com.rxyb.rabbitmq.config.enums.QueueEnums;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author YJH
 * @version 1.0
 * @description
 * @date 2020/6/3  16:54
 */
@Configuration
public class LogQueueImpl implements EnventQueue {

    /**
     * 获取队列
     *
     * @return
     */
    @Override
    @Bean
    public Queue getQueue() {
        return new Queue(QueueEnums.R_LOG_RECORD.getQueue());
    }

    /**
     * 策略的Exchange交换机实例
     *
     * @return
     */
    @Override
    @Bean
    public AbstractExchange getExchange() {
        return new DirectExchange(QueueEnums.R_LOG_RECORD.getExchange(), true, false);
    }

    /**
     * 队列绑定
     *
     * @return
     */
    @Override
    @Bean
    public Binding bindingExchange() {
        return BindingBuilder.bind(this.getQueue()).to((DirectExchange) this.getExchange()).with(QueueEnums.R_LOG_RECORD.getQueue());
    }
}
